package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("adminShopController")
@RequestMapping("/admin/shop")
@Slf4j
public class ShopController {
    @Autowired
    private RedisTemplate redisTemplate;

    private static final String key="shop_status";
    @GetMapping("/status")
    @ApiModelProperty("获取营业状态")
    public Result<Integer> getStatus(){
        Integer status= (Integer) redisTemplate.opsForValue().get(key);
        return Result.success(status);
    }

    @PutMapping("/{status}")
    @ApiModelProperty("设置营业状态")
    public Result setStatus(@PathVariable Integer status){
        log.info("营业状态：{}",status);
        redisTemplate.opsForValue().set(key,status);
        return Result.success();
    }
}
